/**
 * 
 */
package com.mbengue.corp.apr.ra.util;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * @author MMB11447
 *
 */
public class HibernateUtil {

	private static final SessionFactory SESSION_FACTORY;
	 
    static {
        try {
        	SESSION_FACTORY = new AnnotationConfiguration()
                    .configure().buildSessionFactory();
        } catch (HibernateException ex) {
            // Log exception!
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static Session getSessionFactory()
            throws HibernateException {
        return SESSION_FACTORY.openSession();
    }
}
